package com.stylefeng.guns.rest.modular.attent.service;


import com.baomidou.mybatisplus.mapper.Condition;
import com.stylefeng.guns.rest.common.persistence.dao.AttentUserMapper;
import com.stylefeng.guns.rest.modular.attent.controller.dto.AttentHotRequest;
import com.stylefeng.guns.rest.modular.attent.controller.dto.AttentUserResponse;
import com.stylefeng.guns.rest.modular.users.controller.dto.UserInfoRequest;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by ASUS-PC on 2018/6/26.
 */
@Service
public class AttentUserService {

    @Autowired
    AttentUserMapper attentUserMapper;

    //获取我的关注列表
    public List<AttentUserResponse> getAttentUserList(AttentHotRequest request){
        Map<String,Object> data = new HashedMap();
        data.put("userId",request.getUserId());
        data.put("pageIndex" , (request.getPage()-1)*request.getSize());
        data.put("pageSize",request.getSize());
        return attentUserMapper.getAttentUserList(data);
    }

    //获取我的粉丝列表
    public List<AttentUserResponse> getFensUserList(AttentHotRequest request){
        Map<String,Object> data = new HashedMap();
        data.put("attentId",request.getAttentId());
        data.put("pageIndex" , (request.getPage()-1)*request.getSize());
        data.put("pageSize",request.getSize());
        return attentUserMapper.getFensUserList(data);
    }

    //获取我所有的关注列表
    public List<AttentUserResponse> getAllAttentUserList(UserInfoRequest request){
        return attentUserMapper.selectList(Condition.create().eq("user_id" , request.getUserId()));
    }

    //获取我的粉丝数量
    public List<AttentUserResponse> getAllFensUserList(UserInfoRequest request){
        return attentUserMapper.selectList(Condition.create().eq("attented_user" , request.getUserId()));
    }

}
